//
//  AYMHeadLoginView.m
//  QuickCure
//
//  Created by apple on 16/5/5.
//  Copyright © 2016年 ayumi. All rights reserved.
//

//define this constant if you want to use Masonry without the 'mas_' prefix
#define MAS_SHORTHAND

//define this constant if you want to enable auto-boxing for default syntax
#define MAS_SHORTHAND_GLOBALS

#import "Masonry.h"

#import "AYMHeadLoginView.h"

@implementation AYMHeadLoginView


# pragma mark -
# pragma mark 重写初始化方法
- (instancetype)init {
    
    if (self = [super init]) {
        
        [self setupUI];
        
    }
    
    return self;
}

# pragma mark -
# pragma mark 界面初始化

- (void)setupUI {
    
    self.backgroundColor = LeftHeadViewColor;
    
    //    添加头像
    UIImageView *igv_iconImage = [[UIImageView alloc] init];
    
    igv_iconImage.image = [UIImage imageNamed:@"name"];
    
    [self addSubview:igv_iconImage];
    
    //    添加登录按钮
    UIButton *btn_login = [[UIButton alloc] init];
    
    [btn_login addTarget:self action:@selector(loginBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    btn_login.titleLabel.font = [UIFont systemFontOfSize:leftViewLoginFont];
    
    [btn_login setTitle:@"登录" forState:UIControlStateNormal];
    
    [btn_login setTitleColor:[UIColor darkGrayColor] forState:UIControlStateHighlighted];
    
    [self addSubview:btn_login];
    
    //    添加短信登录按钮
    UIButton *btn_messageLogin = [[UIButton alloc] init];
    
    [btn_messageLogin addTarget:self action:@selector(messageLoaginBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
    btn_messageLogin.titleLabel.font = [UIFont systemFontOfSize:leftViewLoginFont];
    
    [btn_messageLogin setTitle:@"短信注册登录" forState:UIControlStateNormal];
    
    [btn_messageLogin setTitleColor:[UIColor darkGrayColor] forState:UIControlStateHighlighted];
    
    [self addSubview:btn_messageLogin];
    
    
    //    添加头像的约束
    [igv_iconImage makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.equalTo(self).offset(-50);
        make.width.equalTo(36);
        make.top.equalTo(self.top).offset(15);
        
    }];
    
    
    //    添加登录按钮的约束
    [btn_login makeConstraints:^(MASConstraintMaker *make) {
        
        make.trailing.equalTo(self.mas_centerX).offset(-70);
        make.top.equalTo(igv_iconImage.mas_bottom).offset(5);
        
    }];
    
    
    //    添加短信登录按钮的约束
    [btn_messageLogin makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.equalTo(self.mas_centerX).offset(-50);
        make.top.equalTo(btn_login);
        
    }];
    
    
    
}




# pragma mark -
# pragma mark 按钮点击事件
- (void)loginBtnClick:(UIButton *)button {
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"UserLoginNoti" object:nil];
    
}


- (void)messageLoaginBtnClick:(UIButton *)button {
    
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"UserLoginByMessageNoti" object:nil];
}
@end
